var websocket;
function initSocket(uri) {
	websocket = new WebSocket(uri);
	websocket.onopen = function(evt) {
		onOpen(evt)
	};
	websocket.onclose = function(evt) {
		onClose(evt)
	};
	websocket.onmessage = function(evt) {
		onMessage(evt)
	};
	websocket.onerror = function(evt) {
		onError(evt)
	};
}
function onOpen(evt) {
	console.log("womp open");
}

function onClose(evt) {
	console.log("womp discon");
}

function onMessage(evt) {
	console.log("womp message:" + evt.data);
	createSprites(evt.data);
}

function onError(evt) {
	console.log("womp error:" + evt.data);
}

function doSend(message) {
	console.log("womp send:" + message);
	websocket.send(message);
}